from django.db import models
from django.utils import timezone
import time
import uuid
# Create your models here.

class Content(models.Model):
	name = models.CharField(max_length=100, default='')
	remark = models.CharField(max_length=100, default='')
	img = models.CharField(max_length=500, default = '')
	level = models.IntegerField(default=0)
	isdel = models.IntegerField(default=0)
	def __str__(self):
		return self.name

class Config(models.Model):
	name = models.CharField(max_length=100, default='')
	address = models.CharField(max_length=100, default='')
	content = models.CharField(max_length=500, default = '')
	connecto = models.CharField(max_length=100, default='')
	connecton = models.CharField(max_length=100, default='')
	connectt = models.CharField(max_length=100, default='')
	connecttn = models.CharField(max_length=100, default='')
	def __str__(self):
		return self.name

class Product(models.Model):
	content = models.ForeignKey(Content, on_delete=models.CASCADE)
	pid = models.CharField(max_length = 50, default=str(uuid.uuid1()))#id
	remark = models.CharField(max_length = 500)#描述
	img = models.CharField(max_length = 1100)#图片地址（预览图，五张左右）
	name = models.CharField(max_length = 50)#名字
	price = models.CharField(max_length = 100)#参考价
	types = models.IntegerField()#类别
	shortname = models.CharField(max_length = 10)#缩写
	ishas = models.IntegerField(default=0)#是否有货 0 无货 1 有货
	isdel = models.IntegerField(default = 0)#是否删除 0 不删除 1 删除
	isrecommend = models.IntegerField(default = 0)#是否推荐 0 不推荐 1 推荐
	createtime = models.DateField(default=timezone.now())#创建时间
	def __str__(self):
		return self.name

class User(models.Model):
	name = models.CharField(max_length = 30)
	isv = models.IntegerField(default = 0)
	wechat_id = models.CharField(max_length = 100)
	info = models.CharField(max_length = 300)
	headimg = models.CharField(max_length = 100)
	def __str__(self):
		return self.name




#下一版开放
class Evaluation(models.Model):
	pro = models.ForeignKey(Product, on_delete=models.CASCADE)
	user = models.ForeignKey(User, on_delete = models.CASCADE)
	eid = models.CharField(max_length = 30)
	content = models.CharField(max_length = 300)
	uname = models.CharField(max_length = 20)
	createtime = models.DateTimeField(default = timezone.now)
	def __str__(self):
		return self.uname



